package cn.sofwin.day0129.homework;

import java.util.Scanner;

public class Homework {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int age = -1;
        System.out.print("请输入年龄：");
        try {
            age = setAge(sc.nextInt());
        }catch (Exception e){
            e.printStackTrace();
        }
        System.out.println(age);
    }

    static public int setAge(int age) throws Exception{
        if (age > 100 || age < 1){
            throw new Exception("年龄必须在1到100之间！");

        }
        return age;
    }

}
